﻿using MediatR;
using T_Person.BaseRep.Interface;
using T_Person.Domain;
using T_Person.Read.APi.Applaction.Command;

namespace T_Person.Read.APi.Applaction.CommandHandlers
{
    public class EmployeementSearchBynameHandlers : IRequestHandler<EmployeeSearchBynameCommand, Employee>
    {
        private readonly IEmployeeRep employeeRep;

        public EmployeementSearchBynameHandlers(IEmployeeRep employeeRep)
        {
            this.employeeRep = employeeRep;
        }

        public async Task<Employee> Handle(EmployeeSearchBynameCommand request, CancellationToken cancellationToken)
        {
            var list = await employeeRep.GetAloneByresult(x => x.Ename == request.name);
            return await Task.FromResult(list);
        }
    }
}
